home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Development Environments ƒ / Perl 4.0.2 ƒ / UnixFiles.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-19  |  3.8 KB  |  155 lines

  1. /*********************************************************************
  2. File        :    UnixFiles.h        -    Macintosh implementation of some things 
  3.                                         useful for handling UN*X files and such.
  4. Author    :    Matthias Neeracher <neeri@iis.ethz.ch>
  5. Started    :    28May91                                Language    :    MPW C
  6.                 28May91    MN    Created
  7.                 28May91    MN    isatty()
  8.                 09Dec91    MN    Radical overhaul
  9.                 15Dec91    MN    mkdir(), FSpUp, FSpDown
  10. Last        :    15Dec91
  11.  
  12. Copyright (c) 1991, 1992 Matthias Neeracher
  13.  
  14.     You may distribute under the terms of either the GNU General Public
  15.     License or the Artistic License, as specified in the README file.
  16.  
  17. *********************************************************************/
  18.  
  19. /* Pathnames Macintosh-style (with ':' as a directory separator). 
  20.     This code is not A/UX compatible and doesn't know about System 7 aliases
  21.     (because it's author doesn't know, either :-) and AppleTalk access
  22.     rights (too complicated right now).
  23.     
  24.     Unix interfaces are generally built after their description in the 
  25.     SunOS 3.0 manpages
  26. */
  27.  
  28. /**************** Routines dealing with paths ********************************/
  29.  
  30. #include <Types.h>
  31. #include <Files.h>
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. /* None of the following routines depend on System 7 running. */
  38.  
  39. /* Convert a working directory & file name into a FSSpec. */
  40. OSErr WD2FSSpec(short wd, ConstStr31Param name, FSSpec * desc);
  41.  
  42. /* Convert a FSSpec into a full pathname. */
  43. char * FSp2FullPath(const FSSpec * desc);
  44.  
  45. /* Works like FSp2FullPath, but creates a *relative* pathname if the object
  46.    is contained in the current directory.  
  47. */
  48. char * FSp2RelPath(const FSSpec * desc);
  49.  
  50. /* Call GetCatInfo for file system object. */
  51. OSErr    FSpCatInfo(const FSSpec * desc, CInfoPBRec * info);
  52.  
  53. /* Is Object a file ? */
  54. Boolean IsFile(const CInfoPBRec * info);
  55.  
  56. /* Return FSSpec of (vRefNum, parID) */
  57. OSErr FSpUp(FSSpec * desc);
  58.  
  59. /* Return FSSpec of file in directory denoted by desc */
  60. OSErr FSpDown(FSSpec * desc, ConstStr31Param name);
  61.  
  62. /* Return FSSpec of nth file in directory denoted by (vRefNum, parID) */
  63. OSErr FSpIndex(FSSpec * desc, short n);
  64.  
  65. /* Convert a pathname into a file spec. */
  66. OSErr Path2FSSpec(const char * path, FSSpec * desc);
  67.  
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71.  
  72. /*************** Stat related stuff *****************************************/
  73.  
  74. #include <time.h>
  75.  
  76. typedef unsigned short     u_short;
  77. typedef long                off_t;
  78. typedef short                dev_t;
  79. typedef long                ino_t;
  80.  
  81. /* mode information */
  82.  
  83. #define     S_IFMT    0170000
  84. #define  S_IFDIR    0040000
  85. #define    S_IFCHR    0020000
  86. #define    S_IFBLK    0060000
  87. #define    S_IFREG    0100000
  88. #define    S_IFLNK    0120000
  89. #define    S_IFSOCK    0140000
  90.  
  91. #define S_ISUID    0004000
  92. #define S_ISGID    0002000
  93. #define S_ISVTX    0001000
  94. #define S_IREAD    0000400
  95. #define S_IWRITE    0000200
  96. #define S_IEXEC    0000100
  97.  
  98. /* Group and others permission is same as owner */
  99.  
  100. struct stat    {
  101.     dev_t        st_dev;        /* Set to vol. refNum.     */
  102.     ino_t        st_ino;        /* Set to file ID          */
  103.     u_short    st_mode;
  104.     short        st_nlink;    /* Always 1                    */
  105.     short        st_uid;        /* Set to 0                    */
  106.     short        st_gid;        /* Set to 0                    */
  107.     dev_t        st_rdev;        /* Set to 0                    */
  108.     off_t        st_size;
  109.     time_t    st_atime;    /* Set to st_mtime         */
  110.     time_t    st_mtime;
  111.     time_t    st_ctime;
  112.     long        st_blksize;
  113.     long        st_blocks;
  114. };
  115.  
  116. #ifdef __cplusplus
  117. extern "C" {
  118. #endif
  119.  
  120. int    stat(char * path, struct stat * buf);
  121. int    lstat(char * path, struct stat * buf);
  122. int    fstat(int fd, struct stat * buf);
  123. int    isatty(int);
  124.  
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128.  
  129. /*************** Directory related stuff *****************************************/
  130.  
  131. typedef struct dir DIR;
  132.  
  133. #define MAXNAMLEN    31
  134.  
  135. typedef struct direct {
  136.     short    d_namelen;
  137.     char  d_name[MAXNAMLEN + 1];
  138. } direct;
  139.  
  140. #ifdef __cplusplus
  141. extern "C" {
  142. #endif
  143.  
  144. DIR *     opendir(char * name);
  145. direct *    readdir(DIR * dirp);
  146. long        telldir(DIR * dirp);
  147. void        seekdir(DIR * dirp, long loc);
  148. void        rewinddir(DIR * dirp);
  149. void        closedir(DIR * dirp);
  150. int        chdir(char * path);
  151. int        mkdir(char * path);
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155.